package org.codingq92.basic.thread;

import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

public class CaseThread {
    public static void main(String[] args) {
        ThreadOne threadOne = new ThreadOne();
        threadOne.start();

        ThreadTwo threadTwo = new ThreadTwo();
        new Thread(threadTwo).start();

        ThreadThree threadThree = new ThreadThree();
        FutureTask<Integer> task = new FutureTask<>(threadThree);
        new Thread(task).start();
        // 获取返回值
        try {
            Integer o = task.get();
        }catch (Exception e) {
            e.printStackTrace();
        }
    }
}

class ThreadOne extends Thread {
    @Override
    public void run() {
        System.out.println("extends Thread...");
    }
}

class ThreadTwo implements Runnable {
    @Override
    public void run() {
        System.out.println("implements Runnable...");
    }
}

class ThreadThree implements Callable<Integer> {
    @Override
    public Integer call() throws Exception {
        System.out.println("implements Callable...");
        return 1;
    }
}
